import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'

Vue.config.productionTip = false
// element
import 'element-ui/lib/theme-chalk/index.css';
import element from './utlis/element-ui'
Vue.use(element)
// axios
// import axios from './utlis/axios'
// Vue.prototype.$axios = axios;
// echarts
import echarts from 'echarts'
// 路由守卫
router.beforeEach((to, from, next) => {
  let data = sessionStorage.getItem('user');
  if (to.path.indexOf('/admin')>-1) {
    if (to.path == '/admin/login') {
      if (data) {
        next('/admin/home')
      }
    } else {
      if (!data) {
        next('/admin/login')
      }
    }
  }
  next();
})
Vue.prototype.$echarts = echarts
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
